import logging
import requests
from common.utils import ordertoken, exe_sql
from config import Base_Host
class Mepsking_Login:
    def register(self,json_dict):
        register_sql="DELETE FROM customer_customer WHERE account in('1213071100567@qq.com','09@qq.com')"
        exe_sql(register_sql)
        url=Base_Host+"/api/meps/customer/register"
        resp=requests.post(url=url,json=json_dict)
        logging.info('注册接口返回的数据为：{}'.format(resp.json()))
        return resp
    def login(self,json_dict):
        url=Base_Host+'/api/meps/customer/login'
        resp=requests.post(url=url, json=json_dict)
        logging.info('登录接口返回的数据是：{}'.format(resp.json()))
        print('登录接口返回的数据是：{}'.format(resp.json()))
        return resp
    def token(self,json_dict):
        resp=self.login(json_dict)
        token=resp.json().get('result').get('accessToken')
        logging.info('获取到的token为：{}'.format(token))
        return token
if __name__ == '__main__':
    # for i in range(10):
    resp=Mepsking_Login()
    # re=ordertoken()
    json_dict ={"account": "2524726232@qq.com '--", "password": "8c730e7f3dac74144", "sourceFrom": "PC"}
    resp.login(json_dict)

